import {SysDeptDataQuery, SysDeptType, SysDictType} from "@/types/system";
import request from "@/utils/request";

const baseUrl = '/system/dept';

export function getDeptTree() {
    return request({
        url: `${baseUrl}/tree`,
        method: 'GET',
    });
}

export function getDeptList(parentId: number | string) {
    return request({
        url: `${baseUrl}/list?parentId=${parentId}`,
        method: 'GET',
    });
}
export function add(data: SysDictType) {
    return request({
        url: `${baseUrl}`,
        method: 'POST',
        data,
    });
}

export function update(data: SysDictType) {
    return request({
        url: `${baseUrl}`,
        method: 'PUT',
        data,
    });
}

export function deleteById(id: string) {
    return request({
        url: `${baseUrl}/${id}`,
        method: 'DELETE',
    });
}

export function deptTypeList(query: SysDeptDataQuery, pageNum = 1, pageSize = 20) {
    return request({
        url: `/system/deptType/list`,
        method: 'GET',
    });
}

export function deptTypeAdd(data: SysDeptType) {
    return request({
        url: `/system/deptType`,
        method: 'POST',
        data,
    });
}

export function deptTypeUpdate(data: SysDeptType) {
    return request({
        url: `/system/deptType`,
        method: 'PUT',
        data,
    });
}

export function deptTypeDelId(id: string) {
    return request({
        url: `/system/deptType/${id}`,
        method: 'DELETE',
    });
}
